package com.example.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

/**
 * @author :   luojie
 * date:     2019/11/3 12:02
 * description:
 */
@RestController("helloController")
@RequestMapping(value = "/hello")
@Api(tags = "测试接口")
@CrossOrigin //跨域访问 swagger 要使用到
public class HelloController {

    private Logger logger = LoggerFactory.getLogger(HelloController.class );

    @ApiOperation("查询所有部门的信息")
    @GetMapping("/list")
    public String list() {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");

        logger.info("查询所有部门的信息开始[uuid:{}]", uuid);

        logger.info("查询所有部门的信息成功[uuid:{}]", uuid);
        return "hello";
    }

    @ApiOperation("获取详情信息")
    @GetMapping("/detail/{id}")
    public Integer detail(@PathVariable("id") Integer id) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");

        logger.info("获取详情信息开始[uuid:{}]", uuid);

        logger.info("获取详情信息成功[uuid:{}]", uuid);
        return id;
    }

    @ApiOperation("分页查询")
    @GetMapping("/page")
    public String page(@PathVariable("id") Integer id) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");

        logger.info("分页查询开始[uuid:{}]", uuid);

        logger.info("分页查询成功[uuid:{}]", uuid);
        return "page";
    }
}
